// miniprogram/pages/loading/loading.js
import {getQueryCodeOptions} from "../../service/Open";
import {getStorageSync} from "../../utils/Storage";
Page({

    /**
     * 页面的初始数据
     */
    data: {
        show: false
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        !getStorageSync("userInfo") ? this.setData({show: true}) : null
        this.getQueryOptions(options);
    },

    /*
    * 获取解析参数
    * */
    getQueryOptions: async function (options) {
        try {
            let md5 = options.scene;
            if (md5) { //是扫码进入
                let res = await getQueryCodeOptions(md5);
                wx.redirectTo({url: res.path});
            } else {
                wx.switchTab({url: "/pages/home/index/index"})
            }
        } catch (e) {
            wx.switchTab({url: "/pages/home/index/index"})
            console.error(e)
        }
    }

})